//
//  BianJiZiLiaoViewController.m
//  JuBoCRM
//
//  Created by iMac on 2024/2/23.
//  Copyright © 2024 iningKe. All rights reserved.
//

#import "BianJiZiLiaoViewController.h"
#import "XiuGaiYongHuMingViewController.h"
#import "nsdate+Helper.h"
@interface BianJiZiLiaoViewController ()
@property (weak, nonatomic) IBOutlet TPKeyboardAvoidingScrollView *mainScrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topSpace;
@property (weak, nonatomic) IBOutlet UIImageView *heeadImage;
@property (weak, nonatomic) IBOutlet UITextField *nameLabel;
@property (weak, nonatomic) IBOutlet UITextField *buMenLabel;
@property (weak, nonatomic) IBOutlet UITextField *phoneLabel;

@end

@implementation BianJiZiLiaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    self.customNavBar.title = @"编辑资料";
 
    _topSpace.constant = NavaBarHeight;
    
    if (@available(iOS 11.0, *)) {
        self.mainScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
//    [_heeadImage sd_setImageWithURL:WebImagePath(GetHandleString(USERINFO, @"img")) placeholderImage:HeadImagePlaceholder];
    _heeadImage.image = _image;
    _nameLabel.text = GetHandleString(USERINFO, @"realname");
    _buMenLabel.text = GetHandleString(USERINFO, @"deptName");
    _phoneLabel.text = GetHandleString(USERINFO, @"mobile");
}

//拍照
- (IBAction)paiZhao:(UIButton *)sender {
    [GetPhoto getPhoto:self completion:^(UIImage *curImage, NSData *imageData) {
        _heeadImage.image = curImage;
        NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
        [tempDic setValue:imageData forKey:@"data"];
        [tempDic setValue:[NSString stringWithFormat:@"%f.png",[[NSDate date] timeStamp]] forKey:@"name"];
        NSArray *array = @[tempDic];

        [[ZZPRequest getWebUtil] uploadImageRequestURLString:@"/adminUser/updateImg" andParas:nil andImageArray:array andShowHud:YES andTransferGottenData:^(id info, NSError *error) {
            if(!error){
                if(_changeBlock){
                    _changeBlock(curImage);
                }
                [ZZPUtils showWarning:@"修改成功"];
            }
        }];
    }];
}




//修改用户名
- (IBAction)mingZi:(UITapGestureRecognizer *)sender {
    XiuGaiYongHuMingViewController *xiuGai = [[XiuGaiYongHuMingViewController alloc] init];
    xiuGai.changeResultBlock = ^(NSString * _Nonnull result) {
        _nameLabel.text = result;
        if(_changeBlock){
            _changeBlock(nil);
        }
    };
    [self pushViewController:xiuGai];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
